<?php
$aksi="modul/mod_news_email/aksi_email.php";
switch($_GET['act']){
  // Tampil Kategori
  default:
    echo "<h2>Email Newsleter</h2>
          <input type=button class='tombol' value='Tambah Email' 
          onclick=\"window.location.href='?module=news_email&act=tambahemail';\">
          <table>
          <tr><th>No</th><th>Alamat Email</th><th>Aksi</th></tr>"; 
    $tampil=mysql_query("SELECT * FROM email ORDER BY name asc");
    $no=1;
    while ($r=mysql_fetch_array($tampil)){
       echo "<tr><td>$no</td>
             <td>$r[name]</td>
             <td><a href=?module=news_email&act=editemail&id=$r[name]><b>Edit</b></a> | 
	               <a href=$aksi?module=news_email&act=hapus&id=$r[name]><b>Hapus</b></a>
             </td></tr>";
      $no++;
    }
    echo "</table>";
    break;
  
  // Form Tambah Kategori
  case "tambahemail":
    echo "<h2>Tambah Email</h2>
          <form method=POST action='$aksi?module=news_email&act=input'>
          <table>
          <tr><td>Alamat Email</td><td> : <input type=text name='email'></td></tr>
          <tr><td colspan=2><input type=submit name=submit class='tombol'  value=Simpan>
                            <input type=button class='tombol'  value=Batal onclick=self.history.back()></td></tr>
          </table></form>";
     break;
  
  // Form Edit Kategori  
  case "editemail":
    $edit=mysql_query("SELECT * FROM email WHERE name='$_GET[id]'");
    $r=mysql_fetch_array($edit);

    echo "<h2>Edit Email</h2>
          <form method=POST action=$aksi?module=news_email&act=update>
          <input type=hidden name=id value='$r[name]'>
          <table>
          <tr><td>Alamat Email</td><td> : <input type=text name='name' value='$r[name]'></td></tr>
          <tr><td colspan=2><input type=submit class='tombol' value=Update>
                            <input type=button class='tombol' value=Batal onclick=self.history.back()></td></tr>
          </table></form>";
    break;  
}
?>
